<?php
/**
 * 前台首页
 * [ranknow bbs!] (C)2009-2015 ranknow.cn.
 *
 * @author liwei
 * @This is NOT a freeware, use is subject to license terms
 * @rcsfile $RCSfile: index.php,v $
 * @revision $Revision: 0.1 $
 * @date $Date: 2009/12/30 09:40:17 $
 */
require 'config.inc.php';
include BBS_MDL_PATH . 'mdl_forum.php';
include BBS_MDL_PATH . 'mdl_thread.php';

$thread_list = array();
$post_list = array();
$action = $_GET['action']?$_GET['action']:'';
$fid = $_GET['fid']?$_GET['fid']:0;
$tid = $_GET['tid']?$_GET['tid']:'';
$offset = $_GET['page']?( int )$_GET['page']:0;
dbConnect();
$template_data['forum_list'] = get_forum_list( 0, 100 );
if ( $action == '' || $action == 'categories' ) {
    $thread_list = get_thread_list( $offset, 10, $fid, array( 'fid' ) );
    $template_data['thread_list'] = $thread_list;
    $template_data['forum'] = get_forum_by_id( $fid );
} elseif ( $action == 'viewthread' ) {
    include BBS_MDL_PATH . 'mdl_post.php';
    $template_data['tid'] = $tid;
    inc_thread_views($tid);
    $template_data['thread'] = get_thread_by_id( $tid );
    $template_data['first_post'] = get_first_post( $tid );
    $post_list = get_post_list( $offset, 10, $tid,array('tid') );
    $template_data['post_list'] = $post_list;
}
$template_data['fid'] = $fid;
$template_data['action'] = $action;
$template = front_load_template( 'index.html' );
$template -> display( $template_data );
windowNoCache();
dbDisconnect();
?>